package com.mygdx.game.Stage.Fight;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;

public class ExampleMainActor extends Fighter {
    public ExampleMainActor() {
        super("Character/ProtagonistFight");
    }

    @Override
    public void roundAction() {
        System.out.println("主人公回合结束动作");
        new Thread(){
            @Override
            public void run() {
                for (int i=0;i<3;i++){
                    for (int j=0;j<30;j++){
                        y=y+2;
                        setPosition(x,y);
                        try {
                            sleep(1);
                        }catch (Exception e){

                        }
                    }
                    for (int j=0;j<30;j++){
                        y=y-2;
                        setPosition(x,y);
                        try {
                            sleep(1);
                        }catch (Exception e){

                        }
                    }
                }
            }
        }.start();

    }

    @Override
    public void action1() {
        System.out.println("卡牌-主角动作1");
        new Thread(){
            @Override
            public void run() {
                for (int j=0;j<30;j++){
                    x=x+40;
                    setPosition(x,y);
                    try {
                        sleep(1);
                    }catch (Exception e){

                    }
                }
                try {
                    sleep(500);
                }catch (Exception e){

                }
                for (int j=0;j<300;j++){
                    x=x-4;
                    setPosition(x,y);
                    try {
                        sleep(1);
                    }catch (Exception e){

                    }
                }
            }
        }.start();
    }
    @Override
    public void action2(){
        new Thread(){
            @Override
            public void run(){
                Actor presentActor = new Actor() {
                    public void draw(Batch batch, float parentAlpha) {
                        Texture t=new Texture("Character/shield.png");
                        batch.draw(t,0,400);
                    }
                };
                //缩放后的大小和位置，我们可以根据原始的位置和大小，以及缩放后的大小
                // -- >> 计算缩放后的位置。
                Action xiao = Actions.parallel(Actions.sizeTo(150, 140.8f, 1), Actions.moveTo(390f, 407.6f, 1));
                System.out.println("1111111");
                //原始的大小和位置
                Action da = Actions.parallel(Actions.sizeTo(190, 176, 1), Actions.moveTo(370, 390, 1));
                presentActor.addAction(Actions.forever(Actions.sequence(xiao, da)));
                for(int j=0;j<30;j++){

                    try {
                        sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }.start();
    }
}
